package com.wj.jiangan.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wj.jiangan.mapper.OrderMapper;
import com.wj.jiangan.pojo.Emp;
import com.wj.jiangan.pojo.Order;
import com.wj.jiangan.pojo.vo.OrderVo;
import com.wj.jiangan.service.IOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author wj
 * @since 2019-11-05
 */
@Service
public class OrdersServiceImpl implements IOrderService {

    @Autowired
    private OrderMapper orderMapper;


    @Override
    public IPage<OrderVo> findOrderByPage(Page page, Map<String, Object> param) {

        Integer ris = (Integer) param.get("ris");
        Integer pid = (Integer) param.get("pid");
        Integer eid = (Integer) param.get("eid");
        Integer cid = (Integer) param.get("cid");

        return orderMapper.queryByPage(page, ris, pid, eid, cid);

    }

    @Override
    public int saveOrder(Order order) {

        return orderMapper.insert(order);
    }

    @Override
    public IPage<OrderVo> queryOrderDetailByPage(Page page, Integer rid) {
        return orderMapper.queryOrderDetailByPage(page, rid);
    }

    @Override
    public List<Object> queryOrderByid(Integer cid){
        QueryWrapper<Order> qw = new QueryWrapper<>();
        qw.eq("c_id",cid);
        qw.select("e_id");
        List<Object> objects = orderMapper.selectObjs(qw);
        return objects;
    }
}
